home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2733 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: File Size!
  5. Date: Tue, 23 Jan 96 13:12:31 GMT
  6. Organization: none
  7. Message-ID: <822402751snz@genesis.demon.co.uk>
  8. References: <4e11ph$733@hammerhead.dadd.ti.com> <4e2fh6$1n4@comet.connix.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4e2fh6$1n4@comet.connix.com>
  15.            shawley@connix.com "Scott Hawley" writes:
  16.  
  17. >
  18. >write a script to use the -l option but only display the size. It should
  19. >take about 1 minuite to write the script.
  20. >hint1: ls | cut
  21. >or
  22. >hint2: ls | awk
  23.  
  24. It would be *extremely* poor C code that shell'd out to execute ls and
  25. cut/awk just to find a file size. The standard C method is to use
  26. fopen/fseek/ftell where SEEK_END is supported. The Unix/POSIX approach is
  27. to use stat/fstat which is a lot more efficient (and also more portable)
  28. than using external commands.
  29.  
  30. -- 
  31. -----------------------------------------
  32. Lawrence Kirby | fred@genesis.demon.co.uk
  33. Wilts, England | 70734.126@compuserve.com
  34. -----------------------------------------
  35.